package com.jqb.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class RequestAndResponse extends HttpServlet {
	private static final long serialVersionUID = 1L;
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		/*重定向方式一*/
//		response.sendRedirect("http://www.baidu.com");
		/*重定向方式二*/
//		response.setHeader("Location", "http://www.baidu.com");
//		response.sendRedirect(null);
		/*重定向方式三*/
		response.setHeader("Refresh", "5;url=http://www.baidu.com");
//		response.sendRedirect(null);
		/*服务器内部请求转发*/
//		request.getRequestDispatcher("Http").forward(request, response);
	}
}
